﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Steer
{
    public partial class PursueTest : UserControl
    {
        public PursueTest()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(PursueTest_Loaded);
        }

        void PursueTest_Loaded(object sender, RoutedEventArgs e)
        {
            mySeeker.x = 400;
            myPursuer.x = 400;
            myTarget.position = new Vector2D(200, 100);
            myTarget.velocity.length = 15;
            myTarget.velocity.angle = Math.PI / 4;

            CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
        }

        void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            mySeeker.seek(myTarget.position);
            mySeeker.update();

            myPursuer.pursue(myTarget);
            myPursuer.update();

            myTarget.update();
        }
    }
}
